﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.materialtypeinfo
{
    public partial class Modify : Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    int mtid = (Convert.ToInt32(Request.Params["id"]));
                    ShowInfo(mtid);
                }
            }
        }

        private void ShowInfo(int mtid)
        {
            lcs.BLL.materialtypeinfo bll = new lcs.BLL.materialtypeinfo();
            lcs.Model.materialtypeinfo model = bll.GetModel(mtid);
            this.lblmtid.Text = model.mtid.ToString();
            this.txtmtname.Text = model.mtname;

        }

        public void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (this.txtmtname.Text.Trim().Length == 0)
            {
                strErr += "物料类别名称不能为空！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int mtid = int.Parse(this.lblmtid.Text);
            string mtname = this.txtmtname.Text;


            lcs.Model.materialtypeinfo model = new lcs.Model.materialtypeinfo();
            model.mtid = mtid;
            model.mtname = mtname;

            lcs.BLL.materialtypeinfo bll = new lcs.BLL.materialtypeinfo();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "List.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("List.aspx");
        }
    }
}
